<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const obj = {
            num:10,
            set(newNum){
                if(newNum<10){
                    throw new Error("人数太少不开办")
                }else{
                    this.num = newNum;
                }
            },
            get(){
                return "目前在班人数"+this.num
            }
        }

        obj.set(5) 
        console.log(obj.get());

    </script>
</body>
</html>